// Register sidebar_widget_expandable
BloggerExt.sidebar_widget_expandable = function() {

    // find containers to expandable.
    jQuery.each(BloggerExtOptions.sidebar_widget_expandable_ids, function(i) {
        // find widget container with class name
        jQuery('#'+this).each( function(j){
                var widgetId = this.id;
                var titleObj = jQuery(this).children('h2:eq(0)');
                var contentObj = jQuery(this).children('div:eq(0)');
				var animate_str = "";
				if(BloggerExtOptions.sidebar_widget_expandable_animate) {
					var animate_str = "'fast',";
				}else {
					var animate_str = ").each(";
				}
                var link = "<span class=\"sidebar-widget-expand\"><a onclick=\"jQuery('#"+widgetId+" .widget-content').toggle("+animate_str
					      +"function(){ "
                          +"  jQuery(this).is(':hidden') ? "
                          +"  jQuery('#"+widgetId+" a:eq(0)').html(BloggerExtOptions.sidebar_widget_expan_title) : "
                          +"  jQuery('#"+widgetId+" a:eq(0)').html(BloggerExtOptions.sidebar_widget_collapse_title)"
                          +"});\">"+BloggerExtOptions.sidebar_widget_expan_title+"</a></span>";
                titleObj.prepend(link);
                contentObj.hide();
        });
    });

};
BloggerExt.sidebar_widget_expandable.user_pref = function() {
	var prefs = [];
	prefs.push({tab_name: 'widget', name: 'sidebar_widget_expandable', display_name:'Expandable:', data_type:'bool', 'default_value': BloggerExtOptions['sidebar_widget_expandable'] });
	prefs.push({tab_name: 'widget', name: 'sidebar_widget_expandable_animate', display_name:'Expand Animate:', data_type:'bool', 'default_value': BloggerExtOptions['sidebar_widget_expandable_animate'] });
	return prefs;
};
BloggerExt.sidebar_widget_expandable.update_pref = function(prefs) {
  BloggerExtUserPrefs['sidebar_widget_expandable'] = (typeof prefs['sidebar_widget_expandable'] != 'undefined') ? true : false ;
  BloggerExtUserPrefs['sidebar_widget_expandable_animate'] = (typeof prefs['sidebar_widget_expandable_animate'] != 'undefined') ? true : false ;
};
BloggerExt.register('sidebar_widget_expandable' ,  {
	sidebar_widget_expandable: true,
	sidebar_widget_expandable_version: 1.2,
	sidebar_widget_expandable_animate: false,
    sidebar_widget_expan_title: '[+]',
    sidebar_widget_collapse_title: '[-]',
    sidebar_widget_expandable_ids: ['Label1','LinkList1','BlogArchive1']
});

